package com.hksj.Intelligentmanagement.controller;

import com.hksj.Intelligentmanagement.common.Rest;
import com.hksj.Intelligentmanagement.dto.FolderDTO;
import com.hksj.Intelligentmanagement.entity.Folder;
import com.hksj.Intelligentmanagement.service.FolderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "music-歌单文件夹")
@RestController
@RequestMapping("/api/folder")
public class FolderController {

	Logger logger = LoggerFactory.getLogger(this.getClass());
	
	@Autowired
	public FolderService folderService;


	@PostMapping("/createFolder")
	@ApiOperation(value = "添加歌单文件")
	public Rest<Folder> createFolder(@RequestBody FolderDTO dto){
		Folder folder = folderService.createFolder(dto);
		return Rest.ok(folder);
	}

	@PostMapping("/updateFolder")
	@ApiOperation(value = "修改歌单文件")
	public Rest updateFolder(@RequestBody FolderDTO dto){
		folderService.updateFolder(dto);
		return Rest.ok();
	}

	@DeleteMapping("/deleteFolder/{id}")
	@ApiOperation(value = "删除歌单文件")
	public Rest deleteFolder(@PathVariable Long id){
		folderService.deleteFolder(id);
		return Rest.ok();
	}

	@GetMapping("/listFolder")
	@ApiOperation(value = "查询歌单文件")
	public Rest<List<Folder>> listFolder(){
		List<Folder> list = folderService.listFolder();
		return Rest.ok(list);
	}
}